package app;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import util.Util;

import java.util.Date;

/**
 * @author yuisama
 * @date 2022/07/06 15:08
 **/
@Data
@NoArgsConstructor
@ToString
@EqualsAndHashCode
public class FileMeta {
    private String name;
    private String path;
    private Boolean isDirectory;
    private Long size;
    private Date lastModified;

    //构造方法不一定包含
    private String pinyin;
    private String pinyinFirst;

    //以下三个方法，保持和add.fxml一致，作为页面显示结果
    private String isDirectoryText;//文件类型

    private String sizeText;//文件大小

    private String lastModifiedText;//文件修改时间

    public void setIsDirectory(Boolean directory) {
        this.isDirectory = directory;
        this.isDirectoryText = Util.parseFileType(this.isDirectory);
    }

    public void setSize(long size) {
        this.size = size;
        this.sizeText = Util.parseSize(this.size);
    }

    public void setLastModified(Date lastModified) {
        this.lastModified = lastModified;
        this.lastModifiedText = Util.parseDate(lastModified);
    }

    public FileMeta(String name, String path, Boolean isDirectory, long size, Date lastModified) {
        this.name = name;
        this.path = path;
        this.isDirectory = isDirectory;
        this.size = size;
        this.lastModified = lastModified;
    }


}